<?php

require '../init.inc.php';

$pages = 3;
$feed = new SimplePie;
$feed->enable_cache(false);

for ($i = 1; $i <= $pages; $i++):

        $feedurl = str_replace('{buzz}', 'basicthinking', TWITTER_SEARCH);
        $feedurl = str_replace('{items}', 100, $feedurl);
        $feedurl = str_replace('{page}', $i, $feedurl);
        $urls[]  = $feedurl; 


endfor;

$feed->set_feed_url($urls);
$feed->init();
$feed->handle_content_type();

foreach ($feed->get_items() as $item):

        $res[] = array (
                'date_sort' => $item->get_date('YmdH'),
                'title' => $item->get_title()
        );

        $statsdate = $item->get_date('ymd');

        if (isset($stats[$statsdate])):

                $stats[$statsdate] = $stats[$statsdate] + 1;
                
        else:
                $stats[$statsdate] = 1;
        endif;


endforeach;

$stats = array_reverse($stats);

$chart = new googChart();
$chart->setChartAttrs( array(
    'type' => 'bar-vertical',
    'data' => $stats,
    'size' => array( 400, 800 )
    ));
echo $chart;

echo "<hr />";

Util::printr($stats);

?>